<?php
namespace app\admin\validate;

use think\Validate;

class Communityclasses extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'row.ocation_id' => 'require|integer|>:0',
        'row.name' => 'require|max:100',
        'row.community_id' => 'integer|>=:0',
        'row.manager_id' => 'integer|>=:0',
        'row.cover' => 'max:255',
        'row.open_apply' => 'in:0,1',
        'row.need_verify' => 'in:0,1',
        'row.show_in_team_list' => 'in:0,1',
        'row.allow_members_view' => 'in:0,1',
        'row.description' => 'max:1000',
        'row.status' => 'in:0,1',
        'row.weigh' => 'integer|>=:0',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'row.ocation_id.require' => '教学点不能为空',
        'row.ocation_id.integer' => '教学点ID必须为整数',
        'row.ocation_id.>' => '教学点ID必须大于0',
        'row.name.require' => '班级名称不能为空',
        'row.name.max' => '班级名称不能超过100个字符',
        'row.community_id.integer' => '社区ID必须为整数',
        'row.community_id.>=' => '社区ID不能为负数',
        'row.manager_id.integer' => '管理员ID必须为整数',
        'row.manager_id.>=' => '管理员ID不能为负数',
        'row.cover.max' => '班级头像路径不能超过255个字符',
        'row.open_apply.in' => '开放申请设置值无效',
        'row.need_verify.in' => '验证设置值无效',
        'row.show_in_team_list.in' => '团队列表显示设置值无效',
        'row.allow_members_view.in' => '成员查看权限设置值无效',
        'row.description.max' => '班级描述不能超过1000个字符',
        'row.status.in' => '状态值无效',
        'row.weigh.integer' => '权重必须为整数',
        'row.weigh.>=' => '权重不能为负数',
    ];

    /**
     * 定义验证场景
     * 格式：'场景名' => ['字段1', '字段2', ...]
     *
     * @var array
     */
    protected $scene = [
        'add' => ['row.ocation_id', 'row.name', 'row.community_id', 'row.manager_id', 'row.cover', 'row.open_apply', 'row.need_verify', 'row.show_in_team_list', 'row.allow_members_view', 'row.description'],
        'edit' => ['row.ocation_id', 'row.name', 'row.community_id', 'row.manager_id', 'row.cover', 'row.open_apply', 'row.need_verify', 'row.show_in_team_list', 'row.allow_members_view', 'row.description', 'row.status', 'row.weigh'],
    ];
}